package org.amn.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

/**
 * <p>
 * 描述:应用配置类
 * </p>
 *
 * @see
 * @author yangjun1120@gmail.com
 *
 */
@Configuration
//@ImportResource("classpath:properties-config.xml") 
//使用这个配置就不需要在xml定义AppConfig 这个bean，
//使用ApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfig.class);
public class AppConfig {

    //    private @Value("${queuekeepalivetime}")
    //    String queueKeepAliveTime;

    /**
     * 队列容量
     */
    private @Value("${queuecapacity}")
    String queueCapacity;

    /**
     * 目录前缀
     */
    private @Value("${prefixdir}")
    String prefixDir;

    /**
     * 备份目录前缀
     */
    private @Value("${bakprefixdir}")
    String bakPrefixDir;

    /**
     * 文件未处理的超时时间
     */
    private @Value("${filetimeout}")
    String fileTimeout;

    /**
     * 目录备份时间间隔
     */
    private @Value("${filebackuptime}")
    String fileBackupTime;

    /**
     * 空目录超时时间
     */
    private @Value("${emptypathtimeout}")
    String emptyPathTimeout;

    /**
     * 两次Dispatcher执行的间隔
     */
    private @Value("${dispatcherdelay}")
    String dispatcherDelay;

    /**
     * 两次Worker执行的间隔
     */
    private @Value("${workerdelay}")
    String workerDelay;

    /**
     * 两次Backuper执行的间隔
     */
    private @Value("${backupperdelay}")
    String backupperDelay;

    public long getDispatcherDelay() {
        return Long.parseLong(dispatcherDelay);
    }

    public long getWorkerDelay() {
        return Long.parseLong(workerDelay);
    }

    public long getEmptyPathTimeout() {
        return Long.parseLong(emptyPathTimeout);
    }

    public long getBackupperDelay() {
        return Long.parseLong(backupperDelay);
    }

    public int getQueueCapacity() {
        return Integer.parseInt(queueCapacity);
    }

    public String getPrefixDir() {
        return prefixDir;
    }

    public String getBakPrefixDir() {
        return bakPrefixDir;
    }

    public void setPrefixDir(String aPrefixDir) {
        this.prefixDir = aPrefixDir;
    }

    public void setBakPrefixDir(String aBakPrefixDir) {
        this.bakPrefixDir = aBakPrefixDir;
    }

    public long getFileTimeout() {
        return Long.parseLong(fileTimeout);
    }

    public long getFileBackupTime() {
        return Long.parseLong(fileBackupTime);
    }

    public void setFileTimeout(long t) {
        this.fileTimeout = Long.toString(t);
    }

}
